#include <iostream>
using namespace std;
#define ARGS_CHECK(argc, num)               \
    {                                       \
        if (argc != num)                    \
        {                                   \
            fprintf(stderr, args error !n); \
            return -1;                      \
        }                                   \
    }
#define ERROR_CHECK(ret, num, msg) \
    {                              \
        if (ret == num)            \
        {                          \
            perror(msg);           \
            exit(1);               \
        }                          \
    }

typedef struct LinkList
{
private:
    typedef struct node
    {
        int val;
        struct node *pre;
        struct node *suc;
    } ND;

    ND *link_create()
    {
        ND *head = new ND;
        // ND &p = *head;
        head->pre = NULL;
        head->suc = NULL;
        return head;
    }

public:
    ND *head = link_create();
    void head_insert(ND *head, int val)
    {
        if (NULL == head)
        {
            cout << "链表未初始化" << endl;
            exit(0);
        }
        ND *new_node = new ND;
        new_node->val = val;
        new_node->pre = head;
        new_node->suc = head->suc;
        if (head->suc)
        {
            head->suc->pre = new_node;
        }
        head->suc = new_node;
    }
    void showList(ND *head)
    {
        if (NULL == head)
        {
            cout << "链表未初始化" << endl;
            exit(0);
        }
        while (head = head->suc)
        {
            cout << head->val << endl;
        }
    }
} LT;
int main(int argc, char *argv[])
{
    LT list;
    list.head_insert(list.head, 1);
    list.head_insert(list.head, 2);
    list.head_insert(list.head, 3);
    list.showList(list.head);
    return 0;
}
